package com.jiang.daily.Q3005;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/09/22 19:28
 */
class Solution {
    public int maxFrequencyElements(int[] nums) {
        int[] cnt = new int[101];
        int maxFrequency = 0;
        int res = 0;
        for (int n: nums) {
            ++cnt[n];
            if (cnt[n] > maxFrequency) {
                res = cnt[n];
                maxFrequency = cnt[n];
            } else if (cnt[n] == maxFrequency) {
                res += maxFrequency;
            }
        }
        return res;
    }
}
